﻿// -----------------------------------------------------------------------
// <copyright file="MemoryClientSession.cs" company="FastNET Services">
//     Copyright (c) 2008-2009. All Rights Reserved.
// </copyright>
// <license>
//     GPLv2
// </license>
// <warranty>
//     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
//     BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
//     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
//     DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </warranty>
// -----------------------------------------------------------------------
#region Usings

using System;
using GateShift.Common.Repository;
using GateShift.Common.Repository.Interfaces.DataInterfaces.System;

#endregion

namespace GateShift.Servers.GameServer.CoreData.MemoryData.Data
{
    /// <summary>
    /// Memory Data class for the Client Session
    /// </summary>
    internal class MemoryClientSession : IClientSessionData
    {
        #region Variables

        private Guid _serverID;
        private DateTime _connectDate;
        private DateTime _tokenExpirationDate;
        private byte[] _sessionToken;

        #endregion

        #region CTor/DTor

        /// <summary>
        /// Initializes a new instance of the MemoryClientSession class
        /// </summary>
        public MemoryClientSession()
        {
            ID = new Identity(Guid.NewGuid());
            IsNew = true;
            IsDirty = true;
        }

        #endregion

        #region State Management

        /// <summary>
        /// Gets or sets a value indicating whether or not this instance has been changed
        /// </summary>
        public bool IsDirty { get; internal set; }

        /// <summary>
        /// Gets or sets a value indicating whether or not this instance is a new entity
        /// </summary>
        public bool IsNew { get; internal set; }

        /// <summary>
        /// Gets or sets a value indicating whether or not this instance has been deleted
        /// </summary>
        public bool IsDeleted { get; internal set; }

        #endregion

        /// <summary>
        /// Gets the Identifier for the instance
        /// </summary>
        public Identity ID { get; private set; }

        /// <summary>
        /// Gets or sets the ID for the server the client is connected to
        /// </summary>
        public Guid ServerID
        {
            get
            {
                return _serverID;
            }

            set
            {
                _serverID = value;
                IsDirty = true;
            }
        }

        /// <summary>
        /// Gets or sets the date the connection was initially set up
        /// </summary>
        public DateTime ConnectDate
        {
            get
            {
                return _connectDate;
            }

            set
            {
                _connectDate = value;
                IsDirty = true;
            }
        }

        /// <summary>
        /// Gets or sets the date the authentication token expires
        /// </summary>
        public DateTime TokenExpirationDate
        {
            get
            {
                return _tokenExpirationDate;
            }

            set
            {
                _tokenExpirationDate = value;
                IsDirty = true;
            }
        }

        /// <summary>
        /// Gets or sets the token used for authentication purposes
        /// </summary>
        public byte[] SessionToken
        {
            get
            {
                return _sessionToken;
            }

            set
            {
                _sessionToken = value;
                IsDirty = true;
            }
        }
    }
}
